_realname=openFPGALoader
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=ci
pkgrel=1
pkgdesc="openFPGALoader: universal utility for programming FPGA (mingw-w64)"
arch=('any')
url="https://github.com/trabucayre/openFPGALoader"
license=('Apache-2.0')
depends=(
  "${MINGW_PACKAGE_PREFIX}-libftdi"
  "${MINGW_PACKAGE_PREFIX}-zlib"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
)

source=()
sha256sums=()

build() {
  cd "${srcdir}"
  mkdir build
  cd build
  MSYS2_ARG_CONV_EXCL=- cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../../../..
  MSYS2_ARG_CONV_EXCL="-DDATA_DIR=" cmake --build .
}

check() {
  "${srcdir}"/build/openFPGALoader.exe --help
}

package() {
  cd "${srcdir}"/build
  make DESTDIR="${pkgdir}" install

  _licenses="${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
  mkdir -p "${_licenses}"
  install -m 644 ../../../../LICENSE "${_licenses}"
}
